<%DIRECTIVE DYNAMIC;%>
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-label="Close">
		<span aria-hidden="true">&times;</span>
	</button>
	<h5 class="modal-title" >修改</h5>
</div>
<form id="eidtForm" role="form" class="form-horizontal parsley-form" data-parsley-validate action="${base}/platform/train/contract/editDo" method="post">
             <div class="modal-body ">
                <input id="id" name="id" value="${obj.contract.id!}" type="hidden">
                <input id="company_id" name="company_id" value="${obj.contract.company_id!}" type="hidden">
                <input id="customer_id" name="customer_id" value="${obj.contract.customer_id!}" type="hidden">
                <input id="student_id" name="student_id" value="${obj.contract.student_id!}" type="hidden">
                <input id="project_id" name="project_id" value="${obj.contract.project_id!}" type="hidden">
                <input id="train_mode" name="train_mode" value="${obj.contract.train_mode!}" type="hidden">
                <input id="source" name="source" value="${obj.contract.source!}" type="hidden">
                <input id="shuttle_mode" name="shuttle_mode" value="${obj.contract.shuttle_mode!}" type="hidden">
                <input id="order_type" name="order_type" value="${obj.contract.order_type!}" type="hidden">
                <input id="order_id" name="order_id" value="${obj.contract.order_id!}" type="hidden">
                <input id="product_id" name="product_id" value="${obj.contract.product_id!}" type="hidden">
                <div class="row mb10">
                    <div class="col-lg-12">
						<div class="form-group">
                            <label for="payment" class="col-sm-2 control-label">客户电话</label>
                            <div class="col-sm-8">
                                <input type="text"  class="form-control"  readonly="readonly"  value="${obj.customer.mobile!}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="payment" class="col-sm-2 control-label">学员来源</label>
                            <div class="col-sm-8">
                                <input type="text"  class="form-control"  readonly="readonly"  value="<%if(obj.contract.source==0){%>平台学员<%}else if(obj.contract.source==1){%>外部学员<%}else{%>教练学员<%}%>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="payment" class="col-sm-2 control-label">培训项目</label>
                            <div class="col-sm-8">
                                <input type="text"  class="form-control"  readonly="readonly"  value="${obj.project.name!}">
                            </div>
                        </div>
                         <div class="form-group">
                            <label for="payment" class="col-sm-2 control-label">培训方式</label>
                            <div class="col-sm-8">
                                <input type="text"  class="form-control"  readonly="readonly"  value="<%if(obj.contract.train_mode=='0'){%>计时<%}else{%>包干<%}%>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="payment" class="col-sm-2 control-label">接送方式</label>
                            <div class="col-sm-8">
                                <input type="text"  class="form-control"  readonly="readonly"  value="<%if(obj.contract.shuttle_mode=='0'){%>无接送<%}else if(obj.contract.shuttle_mode=='1'){%>班车接送<%}else{%>定点接送<%}%>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="payment" class="col-sm-2 control-label">协议产品</label>
                            <div class="col-sm-8">
                                <input type="text"  class="form-control"  readonly="readonly"  value="${obj.product.name!}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="driving_type" class="col-sm-2 control-label">归属驾校</label>
                            <div class="col-sm-8">
                                <select id="school_id" name="school_id" class="form-control" required="required">
                                	<option value="">--选择驾校--</option>
                                	<%for(school in obj.schoolList){%>
                                		 <option value="${school.id}" <% if(obj.contract.school_id==school.id){ %> selected="selected" <% } %>>${school.name}</option>
                                	<%}%>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="driving_type" class="col-sm-2 control-label">分配教练</label>
                            <div class="col-sm-8">
                                <select id="trainer_id" name="trainer_id" class="form-control" required="required" onclick="chooseTrainer();">
                                	<option value="">--选择教练--</option>
                                	<%if(null != obj.trainer){%>
                                		 <option value="${obj.contract.trainer_id}"  selected="selected">${obj.trainer.name}</option>
                                	<%}%>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for=expiry_date class="col-sm-2 control-label">有效期</label>
                            <div class="col-sm-8">
                                <input type="text" id="expiry_date" name="expiry_date" class="form-control"  required="required" value="${obj.contract.expiry_date!}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="finish_date" class="col-sm-2 control-label">结束期</label>
                            <div class="col-sm-8">
                                <input type="text" id="finish_date" name="finish_date" class="form-control"    value="${obj.contract.finish_date!}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="state" class="col-sm-2 control-label">状态</label>

                            <div class="col-sm-8">
                                 <input type="radio" name="state" data-parsley-required="true" value="-1"  <% if(obj.contract.state ==-1){%>checked="checked"<%}%> />已作废
                                 <input type="radio" name="state" data-parsley-required="true" value="0"  <% if(obj.contract.state ==0){%>checked="checked"<%}%> />培训中
                                 <input type="radio" name="state" data-parsley-required="true" value="1"  <% if(obj.contract.state ==1){%>checked="checked"<%}%> />已完成
                                 <input type="radio" name="state" data-parsley-required="true" value="2"  <% if(obj.contract.state ==2){%>checked="checked"<%}%> />已终止
                            </div>
                        </div>
                    </div>
                </div>
                </div>
	<div class="modal-footer">
		<button  class="btn btn-default btn-sm btn-parsley"  >完成</button> 
	</div>
            </form>
<script language="JavaScript">
    $(document).ready(function () {
    	var dialog=$("#editModal");
		$("#editModalDialog").draggable();
        $('#eidtForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    Toast.success(data.msg);
                    datatable.ajax.reload();
	               	dialog.modal("hide");
                } else {
                    Toast.error(data.msg);
                    datatable.ajax.reload();
                 	dialog.modal("hide");
                }
            }
        });
    });
    
    function chooseTrainer(){
    	var schoolId=$('#school_id').val();
    	if(null == schoolId || ""==schoolId){
    		alert("请选择驾校");
    		return ;
    	}
    	$.ajax({
			url : "${base}/platform/train/contract/chooseTrainer",
			data : {
				schoolId : schoolId
			},
			type : "post",
			async : false,
			dataType : "json",
			success : function(data){
				var html="";
				for(var i=0;i<data.length;i++){
					html+=' <option value="'+data[i].id+'">'+data[i].name+'</option>';
				}
				$("#trainer_id").html(html);
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				return false;
			}
		});
    }
</script>

